package org.chameleon.limit.manager;

import com.ctrip.framework.apollo.Config;
import org.chameleon.datasource.manager.apollo.AbsApolloConfigManager;
import org.chameleon.limit.convert.ApolloLimitChangeConvert;
import org.chameleon.limit.convert.JsonLimitConvert;
import org.chameleon.limit.entity.RateLimiterConfig;


/**
 * Apollo配置管理中心，负责读取&更新对应的配置
 */
public class ApolloConfigManger extends AbsApolloConfigManager<RateLimiterConfig> {

    public ApolloConfigManger(Config config) {
        super( config, new ApolloLimitChangeConvert(), new JsonLimitConvert());
    }

    @Override
    public String buildCacheKey(RateLimiterConfig rateLimiterConfig) {
        return rateLimiterConfig.getGroup()+"_"+rateLimiterConfig.getKey();
    }
}
